<template>
  <DataList :name="name" :single="true" :cate="cate" :cols="cols" />
</template>
<script>
import DataList from "@/components/DataList";
import { getUser } from "@/utils/auth";
import { addYls, deleteYls, updateYls, getYls } from "@/api/阅览室机房教室.js";
export default {
  components: {
    DataList
  },
  data() {
    return {
      cate: "A3-3阅览室、机房、教室",
      name:'3.3 阅览室、机房、教室',
      cols: [
        { label: "阅览室座位数(个)", prop: "YLSZWS" },
        { label: "计算机数(台)", prop: "阅览室机房教室_计算机数",
        data:[
          { label: "合计", prop: "JSJS_HJ" },
          { label: "其中：教学用计算机", prop: "计算机数_教学用计算机",
          data:[
            { label: "合计", prop: "JSJS_JXY" },
            { label: "其中：平板电脑", prop: "JSJS_PB" },
          ] },
          { label: "其中：机房用计算机", prop: "计算机数_机房用计算机",
          data:[
            { label: "公共机房", prop: "GGJFJSJS" },
            { label: "专业机房", prop: "ZYJFJSJS" },
          ] },
        ] },
        { label: "教室(间)", prop: "阅览室机房教室_教室",
        data:[
          { label: "合计", prop: "JS_HJ" },
          { label: "其中：网络多媒体教室", prop: "JS_WLDMT" },
        ] },
        
      ]
    };
  },
  methods: {
 
    async fetchData() {
      var user = getUser();
      var datas = await getYls(user.XXID,user.CJPC);
      return datas;
    },
    onadd(model){
      var temp = JSON.parse(JSON.stringify(model))
      return new Promise(async (resolve,reject)=>{
           
      
          console.log(JSON.stringify(temp));
          var model = await addYls(temp);
          resolve(model);
      })
    },
    
    onupdate(model) {
      //
      var temp = JSON.parse(JSON.stringify(model))
      return new Promise(async (resolve,reject)=>{
           
          console.log(JSON.stringify(temp));
          var model = await updateYls(temp);
          resolve(model);
      })
      //
    },
    ondelete(model) {
       var temp = JSON.parse(JSON.stringify(model))
      return new Promise(async (resolve,reject)=>{
        
         await deleteYls(temp);
          resolve();
      })
    }
  }
};
</script>
<style>
</style>